﻿using System.Data;
using ContractManagementSystem.DataAccess;
using ContractManagementSystem.Entity;

namespace ContractManagementSystem.BusinessLogic
{
    public static class MessageBusiness
    {
        public static string ErrorMessage { get; set; }
        private static MessageDataAccess _messageDataAccess;

        public static bool Insert(MessageEntity messageEntity)
        {
            _messageDataAccess = new MessageDataAccess();
            if (_messageDataAccess.Insert(messageEntity))
            {
                return true;
            }
            ErrorMessage = _messageDataAccess.ErrorMessage;
            return false;
        }

        public static bool Update(MessageEntity messageEntity)
        {
            _messageDataAccess = new MessageDataAccess();
            if (_messageDataAccess.Update(messageEntity))
            {
                return true;
            }
            ErrorMessage = _messageDataAccess.ErrorMessage;
            return false;
        }

        public static bool Delete(DataTable source)
        {
            _messageDataAccess = new MessageDataAccess();
            if (_messageDataAccess.Delete(source))
            {
                return true;
            }
            ErrorMessage = _messageDataAccess.ErrorMessage;
            return false;
        }

        public static DataTable FetchAll(string id,int type)
        {
            _messageDataAccess = new MessageDataAccess();
            return _messageDataAccess.FetchAll(id,type);
        }

        public static int FetchNumber(string id)
        {
            _messageDataAccess = new MessageDataAccess();
            return _messageDataAccess.FetchNumber(id);
        }
    }
}
